import {http} from "../../utils/http";
Page({
    data: {
        list: [],            //医院列表
    },
    //页面加载，请求医院列表
    async onLoad() {
        // let result = await this.http()
        // let result =await http("北京",1).catch(err=>{
        //     console.log(err)
        // })
        // this.setData({
        //     list: result.data.showapi_res_body.hospitalList
        // })


        // let result =await http({provinceName:"北京",page:1})
        //  this.setData({
        //     list: result.data.showapi_res_body.hospitalList
        // })

        wx.showLoading({
          title: '正在加载',
        })
        //请求列表页
        let result =await http({
            url:"87-60",
            data:{
                provinceName:"北京",
                page:1
            }
        })

         this.setData({
            list: result.data.showapi_res_body.hospitalList
        })
        wx.hideLoading()            //隐藏loading

        // http({
        //     url:"87-59",

        //     data:{id:"1001"}
        // })


        // http({id:"1001",url:"87-59"})
    },
    http() {
        //返回promise  
        return new Promise((resolve, reject) => {
            let url = "https://route.showapi.com/87-60?showapi_appid=575929&showapi_sign=7e6f88c4aac34625932f4a5b5230b81b&provinceName=北京&page=1"
            wx.request({
                url: url,
                success: res => {
                    resolve(res)
                },
                fail: err => {
                    reject(err)
                }
            })
        })
    },
    //显示tabbar的dot
    handleClick() {
        //显示红色点点
        wx.showTabBarRedDot({
            index: 1,
        })

        //隐藏tabBar
        wx.hideTabBar({
            animation: true,
        })

        //设置导航栏样式
        wx.setTabBarStyle({
            color: "#fff",
            selectedColor: "#ff0000",
            backgroundColor: '#ffff00',
            borderStyle: "black"
        })

        //添加肩章
        wx.setTabBarBadge({
            index: 1,
            text: "99"
        })
    },
    //跳转详情页
    toDetail(e){
        // console.log(e)
        let id=e.currentTarget.id;      //医院id
        //页面跳转
        wx.navigateTo({
          url: '/pages/detail/detail?id='+id,

        })
    }



})